package ui.adapter;

import android.annotation.TargetApi;
import android.view.ViewGroup;


import com.fy.fyzf.R;
import com.fy.fyzf.imgselect.AbstractRender;
import com.fy.fyzf.imgselect.AbstractRenderAdapter;
import com.fy.fyzf.imgselect.AbstractViewHolder;
import com.fy.fyzf.imgselect.ImagePickerRender;

import java.util.List;


public class ImagePickerListAdapter extends AbstractRenderAdapter<String> {

    public ImagePickerListAdapter(List<String> data) {
        this.mDataset = data;
    }

    public AbstractViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
        AbstractViewHolder holder = super.onCreateViewHolder(viewGroup, viewType);
        if (holder != null) {
            return holder;
        }
        ImagePickerRender render = new ImagePickerRender(viewGroup, this);
        AbstractViewHolder articleHolder = render.getReusableComponent();
        articleHolder.itemView.setTag(R.id.list_item, render);
        return articleHolder;
    }

    public List<String> getImgData(){
        return getList();
    }
    @TargetApi(4)
    public void onBindViewHolder(AbstractViewHolder holder, int position) {
        AbstractRender render = (AbstractRender) holder.itemView.getTag(R.id.list_item);
        render.bindData(position);
    }
}

